package com.beta.springmvc.controller;

import com.beta.springmvc.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * Created by yaoyt on 16/12/1.
 *
 * @author yaoyt
 */
@Controller
@RequestMapping("/json")
public class JsonController {

    //http://localhost:8080/json/user
    @ResponseBody
    @RequestMapping("/user")
    public User get() {
        User u = new User();
        u.setId(1);
        u.setName("jayjay");
        u.setBirth(new Date());
        return u;
    }

    @RequestMapping("/error")
    public String error() {
        int i = 5 / 0;
        return "hello";
    }

}
